package com.sec.etech.bpm.plugin.formfield.context;

import com.alibaba.fastjson.JSONObject;
import com.sec.etech.bpm.plugin.formfield.def.FormFieldUserPluginDef;
import com.sec.etech.bpm.plugin.formfield.executer.FormFieldUserPluginExecutor;
import org.openbpm.bpm.api.engine.plugin.def.BpmUserCalcPluginDef;
import org.openbpm.bpm.api.engine.plugin.runtime.RunTimePlugin;
import org.openbpm.bpm.engine.plugin.context.AbstractUserCalcPluginContext;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component("formFieldUserPluginContext")
@Primary
// @ConditionalOnMissingClass({"org.openbpm.bpm.plugin.usercalc.formfield.context.FormFieldUserPluginContext"})
@Scope("prototype")
public class FormFieldUserPluginContext extends AbstractUserCalcPluginContext {

    @Override
    protected BpmUserCalcPluginDef parseJson(JSONObject pluginJson) {
        return (BpmUserCalcPluginDef)pluginJson.toJavaObject(FormFieldUserPluginDef.class);
    }

    @Override
    public String getDescription() {
        FormFieldUserPluginDef def = (FormFieldUserPluginDef)getBpmPluginDef();
        if (def == null) {
            return "";
        }
        return def.getDescription();
    }

    @Override
    public Class<? extends RunTimePlugin> getPluginClass() {
        return FormFieldUserPluginExecutor.class;
    }


    @Override
    public String getTitle() {
        return "表单人员";
    }
}
